package com.hualude.roadsign.controller;

import com.hualude.roadsign.dto.DTRequestDto;
import com.hualude.roadsign.dto.DTResponseDto;
import com.hualude.roadsign.dto.JsonMsgDto;
import com.hualude.roadsign.service.NoticeAppService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * Created by pjn on 2017/4/20.
 */
@Controller
@RequestMapping("/rds_noticeApp")
public class NoticeAppController {
    @Resource
    private NoticeAppService noticeAppService;

    @RequestMapping(value = "/getNoticeAppSended4DT")
    @ResponseBody
    public DTResponseDto getNoticeAppSended4DT(DTRequestDto dtRequestDto, Integer userId) {
        DTResponseDto dtResponseDto = new DTResponseDto();
        try {
            dtResponseDto = noticeAppService.getNoticeAppSended4DT(dtRequestDto, userId);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return dtResponseDto;
    }

    @RequestMapping(value = "/addAppNotice")
    @ResponseBody
    public JsonMsgDto addAppNotice(Integer createUserId, String noticeTitle, String noticeContext, String noticePic) {
        JsonMsgDto dto = new JsonMsgDto();
        try {
            dto.setJsonData(noticeAppService.addAppNotice(createUserId, noticeTitle, noticeContext, noticePic));
            dto.setIsSuccess(true);
        } catch (Exception e) {
            dto.setIsSuccess(false);
            e.printStackTrace();
        }
        return dto;
    }

    @RequestMapping(value = "/getAppPicNotice")
    @ResponseBody
    public JsonMsgDto getAppPicNotice() {
        JsonMsgDto dto = new JsonMsgDto();
        try {
            dto.setJsonData(noticeAppService.getAppPicNotice());
            dto.setIsSuccess(true);
        } catch (Exception e) {
            dto.setIsSuccess(false);
            e.printStackTrace();
        }
        return dto;
    }

    @RequestMapping(value = "/getIsReadNotice")
    @ResponseBody
    public JsonMsgDto getIsReadNotice(Integer userId) {
        JsonMsgDto dto = new JsonMsgDto();
        try {
            dto.setJsonData(noticeAppService.getIsReadNotice(userId));
            dto.setIsSuccess(true);
        } catch (Exception e) {
            dto.setIsSuccess(false);
            e.printStackTrace();
        }
        return dto;
    }
}
